<cfsetting enablecfoutputonly="Yes">
<!---
	where/workit.cfm
--->

<cfmodule template="_head.cfm" pageTitle="Work It">

<cfoutput>
<style type="text/css">
html, body {
	background-color: white;
	color: black;
	font-family: Calibri, Tahoma, Verdana, Arial, 'Bitstream Vera Sans', 'Vera Sans', Helvetica, sans-serif, sans;
	padding: 0;
	margin: 0;
}
body { margin: 0 1em; }
p {
	margin: 0 0 1em 0;
}
##panic {
	padding: 0.5em;
	border: 1px solid ##ffaa00;
	background-color: ##ffeedd;
	margin-top: 2em;
}
input { margin-bottom: 0.5em; padding: 0.25em; }
##Results {
	margin-bottom: 1em;
}
a.result {
	display: block;
	font-size: 90%;
	color: ##777777;
	border-bottom: 1px solid ##ffaa00;
	padding: 4px 4px 8px 20px;
	text-decoration: none;
	background-position: 1px 1px;
	background-repeat: no-repeat;
}
a.result.first {
	border-top: 1px solid ##ffaa00;
}
a.result:hover {
	text-decoration: none;
	background-color: ##fffeee;
}
.result:hover .title {
	text-decoration: underline;
	color: red;
}
.result .title {
	font-weight: bold;
	color: blue;
}
.result .phoneType {
	float: right;
}
.result .details {
	color: ##4488ff;
	margin-left: -20px;
	margin-right: -4px;
	text-align: right;
}
/* .result .street, .result .phone { padding-left: 1em; } */
</style>
<script language="JavaScript" type="text/javascript">
// <![CDATA[
var results = [];
var markers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var lookupid = 0;
function clearSearchResults(lid) {
	document.getElementById("Results").innerHTML = [
		"<p class='bot'>When you find a place you like, click on it to tell others in your area about it.</p>"
	].join("");
	results = [];
	lookupid = lid;
} // clearSearchResults
function addSearchResult(n,title, lat, lng, street, phones) {
	var hits = document.getElementById("Results");
	if(!hits) return false;
	var result = makeDiv(null, "result" + (results.length ? "" : " first"), "a");
	hits.appendChild(result);
	result.href = "##";
	result.id = "result" + n;
	result.onclick = function() { window.parent.openSearchResult(lookupid,this.id.substring(6,this.id.length)); return false; }
	result.style.backgroundImage = 'url(http://www.google.com/mapfiles/gadget/letters/marker' + markers.substring(n,n+1) + '.png)';
	result.appendChild(makeDiv(title,"title"));
	result.appendChild(makeDiv(street,"street"));
	var primaryPhone = null;
	if((phones != null) && (typeof phones == 'object') && (phones.length > 0)) {
		for(var i = 0; i < phones.length; i++) { // >
			var p = makeDiv(phones[i].number,"phone")
			primaryPhone = primaryPhone || phones[i].number;
			result.appendChild(p);
		} // for i
	} // if
	var d = makeDiv("","details");
	d.id = "details" + n;
	result.appendChild(d);
	results.push({
		'title'  : title,
		'lat'    : lat,
		'lng'    : lng,
		'street' : street,
		'phone'  : primaryPhone
	});
	return true;
} // addSearchResult
function finalizeSearchResults() {
	var postBody = 'v=1&lid=' + lookupid;
	for(var i = 0; i < results.length; i++) { // >
		postBody += [
			'&lat', i, '=', escape(results[i].lat || ''),
			'&lng', i, '=', escape(results[i].lng || ''),
			//'&phone', i, '=', escape(results[i].phone || ''),
			//'&street', i, '=', escape(results[i].street || ''),
			'&title', i, '=', escape(results[i].title || '')
		].join('');
	} // for i
	ajax("lookup.cfm", postBody, function(resp){
		var x = resp.documentElement;
		if(x.tagName.toUpperCase() == 'ERROR') { alert(x.text || x.textContent); return false; }
		else if(x.tagName.toUpperCase() != 'PLACES') return false;
		if(x.getAttribute('key') != '#Session.GeoKey#') return false;
		if(x.getAttribute('lid') != lookupid) return false;
		var reqAttrs = String("fooddrinks,foodsolid,days,n,openuntil,outlets,wififree,wifipaid").split(',');
		for(var i = 0; i < x.childNodes.length; i++) { // >
			var p = x.childNodes[i];
			if(p.nodeType != 1) continue;
			if(p.tagName.toUpperCase() != 'PLACE') continue;
			var vals = {};
			for(var j = 0; j < reqAttrs.length; j++) vals[reqAttrs[j]] = p.getAttribute(reqAttrs[j]) || ''; // >
			var d = document.getElementById("details" + vals.n);
			if(d) {
				emptyNode(d);
				var k = [];
				if(vals.wififree == '1') k.push("free wifi");
				else if(vals.wifipaid == '1') k.push("paid wifi");
				else if(vals.wififree == '0') k.push("NO free wifi");
				if(vals.foodsolid == '1') k.push("solid food");
				else if(vals.foodsolid == '0') k.push("NO solid food");
				if(vals.fooddrinks == '1') k.push("drinks");
				else if(vals.fooddrinks == '0') k.push("NO drinks");
				if(vals.outlets == '1') k.push("power outlets");
				else if(vals.outlets == '0') k.push("NO power outlets");
				if(vals.openuntil.match(/^[0-9]+$/)) k.push("open until " + vals.openuntil);
				d.appendChild(document.createTextNode(k.join(", ")));
			} // if d
		} // for i
	}); // ajax
} // finalizeSearchResults
function emptyNode(n) {
	for(var i = n.childNodes.length - 1; i >= 0; i--) {
		n.removeChild(n.childNodes[i]);
	} // for i
} // emptyNode
function makeDiv(t,c,g) {
	if(g == null) g = "div";
	var d = document.createElement(g);
	if(t != null) d.appendChild(document.createTextNode(t));
	if(c != null) d.className = c;
	return d;
} // makeDiv
function ajax(url, vars, callbackFunction){
	var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
	request.open("POST", url, true);
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	request.onreadystatechange = function(){
		if ((request.readyState == 4) && (request.status == 200)) {
			if (request.responseXML){
				callbackFunction(request.responseXML);
			}
		}
	};
	request.send(vars);
} // ajax
// ]]>
</script>
</head>
<body>
<div id="Results">
<p>Great!</p>
<p>Now that you are in the right general area, use the search box in the bottom left corner of the map to find a local business or other place you like to write.</p>
<p>For example, you might search for <em>Library</em> or <em>Starbucks</em>.</p>
</div>
<p>You can also <a href="./" target="_top">start over from the beginning</a> if you want.</p>
</cfoutput>

<cfmodule template="_foot.cfm">

<cfsetting enablecfoutputonly="No">